//
//  JJAssetModel.swift
//  JJAlbum
//
//  Created by 吴梓杭 on 2025/10/11.
//

import UIKit
import Photos

public extension JJAssetModel {
    @objc enum MediaType: Int {
        case unknown = 0
        case image
        case gif
        case livePhoto
        case video
    }
}

public class JJAssetModel: NSObject {
    // 相册id,等于PHAsset.localIdentifier
    @objc public let id: String
    @objc public let asset: PHAsset
    // 相册类型
    @objc public var type: JJAssetModel.MediaType = .unknown
    // 视频转换后时长 hh:mm:ss
    @objc public var durationString = ""
    // 视频时长
    @objc public var second: Int {
        return internal_second
    }

    @objc public init(asset: PHAsset) {
        id = asset.localIdentifier
        self.asset = asset
        super.init()
        internal_init()
    }
    
    public static func == (lhs: JJAssetModel, rhs: JJAssetModel) -> Bool {
        return lhs.id == rhs.id
    }
    
}

